##mystr = 'hello world and itcast and itheima and Python'
#print(mystr.find('and'))
#print(mystr.rfind('and'))
#print(mystr[35])
#print(mystr.find('ands',15,30))
#print(mystr.index('ands'))
#print(mystr.count('and',0,20))
#print(mystr.rsplit(' '))
#print(mystr.replace('and','he'))
#print(mystr.rsplit(' ',2))
#',)
# '''''''str="Hello, Python! I love Python programming."
# index = str.find('Python')
# if index!=
# print(str.find('Python'))
# if str.find('Python')>0:
#     print(str.replace('Python','Java'))'''
# '''mystr =" hello world and itcast and itheima and Python  "
# print(mystr.upper())
# print(mystr.lower())
# print((mystr.rstrip()).capitalize())
# print(mystr.capitalize())
# print(mystr.center(100,"."))'''
# #mystr = 'hello'
# #print(mystr.center(10,'#'))
# '''name= '高永超'
# list = [[1,2,3],[4,5,6],[7,8,9,10]]
# print(name.endswith('超',0,3))
# list_new = [a[i ]for a in list for i in range(len(a))]
# print(list_new)'''
# '''mystr = 'fall!lafjsdl!lafjdl!lfadjl!'
# print(mystr.index('!'))
# print(mystr.find('!',mystr.index('!')+1))
# def find(a):'''
# '''mystr1 = 'hello'
# mystr2 = ('hello12345')
# print(mystr1.isalpha())
# print(mystr2.isalpha())
# print(mystr1.isdigit())
# print(mystr2.isdigit())
# print(mystr1.isalnum())
# print(mystr1.isspace())'''
#
#
# '''def findstr(list,str,num):
#     index_temp=0
#     index_now = 0
#     for i in range(num):
#         index_temp=index_now
#         index_now= list.find(str,index_temp+1)
#     return index_now
# list = input('请输入列表：’）
# str = input('请输入你要找的字符：')
# num = int(input('请输入你要找第几次：'))
# print(findstr(list,str,num))'''
#
#
# '''s1 = {10,20,30,40,50,}
# s3 = {'abcdefg','silfjl'}
# print(s3)
# print(s1)
# s1 = set()
# s2 = {}
# print(type(s1))
# print(type(s2))'''
#
# '''s1 = {10,20}
# s1.add(100)
# s1.add(10)
# print(s1)
# s1.update('slfjs')
# print(s1)
# s1.remove(10)
# print(s1)
# s1.discard(10)
# print(s1.pop())
# print(s1)
# print('l' in s1)'''
#
# '''tuple1 = ('aaa','1',1,'kfds',45,45)
# print(tuple1.index(1))
# print(len(tuple1)'''
#
# name_list =['高永朝','高勇潮','高音草','高永超']
#
# '''name = list(input('请输入您要搜索的名字：'))
#
# if name in name_list:
#     print(f'您输入的名字是{name}，名字已存在')
# else:
#     name_list.extend(name)
#     print(f'您输入的名字是{name}，名字不存在，已添加')'''
# '''
# print(name_list)
# name_list.insert(1,'高吟草')
# print(name_list)
# del name_list[1]
# name_list.pop()
# name_list.remove('高永朝')
# name_list[0]='aaa'
# print (name_list)'''
#
# '''num_list = [2,4,6,8,1,3,564,14,3678,465,4,63,32,2]
# num_list.sort()w
# num_list.sort()
# num_list.reverse()
# print(num_list)
#
# i = 0
# while i<len(num_list):
#
#     print(num_list[i])
#     i = i + 1
# for i in num_list:
#     print(i)'''
#
# '''dict = {'name':'Tom','age':20,'gender':'男'}
# print(dict['name'])
# print(dict.get('nam',123))
# for key in dict.keys():
#     print(key)
# print(dict.items())
# for value in dict.values():
#     print(value)
# for key,value in dict.items():
#     print(f'{key} = {value}')'''
# '''set = {i for i in range(10) if i%2==0}
# print(set)
# list = [1,2,3,4,5,3]
# dict = {n:n**2 for n in range(10)}
# print(dict)'''
#
# '''age = int(input('请输入你的年龄：'))
#
# if age>18:
#     print('已成年，可以上网。')
# elif age == 18:
#     age = 18
#     print('刚满18岁~，可以上网。')
# else :
#     print('未成年，不可以上网。')
# print('系统关闭。')'''
#
# '''age = int (input('请输入您的年龄：'))
# if age<18:
#     print(f'您的年龄是{age}，童工一枚')
# elif age>=18 and age<=60:
#     print(f'您的年龄是{age},合法工龄')
# elif age>60:
#     print(f'您的年龄是{age}，可以退休')'''
#
# '''money = 1
# seat = 1
# if money ==1:
#     if seat==1:
#         print('可以上车')
#     else:
#         print('不可以上车')
#
# elif money !=1:
#     print('高永超与穷鬼''''''
#
# '''import random
# computer = random.randint(0,2)
# print(computer)
# player = int(input('出剪刀输入0，出石头输入1，出布输入2：'))
# if (computer ==0 and player == 1) or (computer == 1 and player == 2)or(computer ==2 and player==0):
#     print('玩家获胜。')
# elif computer == player:
#     print('平局')
# els
#     print('电脑获胜')'''
#
#
# '''a,b = input('请输入两个数，中间用空格隔开：').split()
# a = int(a)b=int(b)'''
#
# '''h,a = input('请输入高度和底边长度：').split()
# h=int(h)
# a=int(a)
# i = 3
# num=1
# print('*'.center(50))
# while i<=h:
#     s = (a-1)/(h-1)
#
#     num =int (num+s)
#
#     print(('*'*num).center(50))
#     i+=1
# print(('*'*a).center(50))'''
#
#
# '''a=100
# sum = 0
# while a>0:
#     sum = a+sum
#     a-=1
# print('任务结束','sum的值为:',sum)
#
# j=0
# while j<=4:
#     i = 0
#     while i<=4:
#         print('*',end=' ')
#         i+=1
#     print()
#     j+=1'''
# '''a = input('请输入一个字符：')
# print(ord(a))'''
#
# '''s = int(input('请输入距离：'))
# tBike = s/3+50
# tWalk = s/1.2
# if tBike<tWalk:
#     print('Bike')
# elif tBike>tWalk:
#     print('Walk')
# else:
#     print('一样快')'''
#
# '''i = 1
# j = 1
# while j<10:
#     i=1
#     while i<=j:
#         print(f'{i}*{j}={i*j}',end = '\t ')
#         i+=1
#     print()
#     j+=1'''
#
# '''str1 = 'itheima'
# for i in str1:
#     if i =='e':
#         print('遇到e不打印')
#         break
#     print(i)'''
#
# '''n=4
# l = 70
# r = 85
# w=[10,10,20,50]
# i=0
# sum1=0
# while i <4:
#     m=1
#     while (i+m)<4:
#         n=2
#         while (i+n)<4:
#             sum = w[i]+w[i+m]+w[i+n]
#             if l<sum<r:
#                 sum1=sum1+1
#                 print(w[i],w[i+m],w[i+n])
#             n=n+1
#         m=m+1
#     i=i+1
# print(sum1)'''
# '''str = input('请输入一个字符串')
# print(str[::-1])'''
# '''figure = ('高永超','20','大学生')
# name,age,career=figure
# print(name,age,career)'''
#
# '''a=3
# b=5
# print(a+b,a-b,a*b,a/b)'''
#
# '''list1 = ['1','2','3']
# print(list1[1])
# print(str(list1))
# str1 = '*'.join(list1)
# print(str1)
#
# i =1
# sum=0
# while i<100:
#     if i%2:
#         sum+=i
#     else:
#         sum-=i
#     i+=1
#
# print(sum)'''
# '''i=0
# s = 0
# base =10000
# while s<=20000:
#     i+=1
#     s= base*(1+0.0325)**i
#
# print(i'''
# '''list1=[[1,2,3],[4,5,6],[7,8,9]]
# list1[0]=[ int(i) for i in input().split()]
# print(list1'''
#
# '''for m in range(180):
#     for n in range(m,m+8):
#         if m*n==6*(m+n) and m!=n:
#             print(m,n)'''
#
# '''for i in range(100):
#     if 999<i**3<10000 and 99999<i**4<1000000 and len(set(str(i**3)+str(i**4)))==10:
#             print(i)'''
# '''file = '''['a.py','b.jbg','c.gif','d.map','e.png','f.jpg','k.txt','f.hif','f.gif','h.png','m.doc']
# '''for i in file:
#     if '.jpg' in i or '.gif' in i or '.png' in i:
#         print(i)'''
#
# '''list1 = [1,2,3,4,5,6,7,8,9,0]
# print(list(enumerate(list1)))
# print(min(list1))
# print(max(list1))
# print([ i for i in range(1,100,2)])
# for index, i in enumerate(list1,2):
#     print(index,end = '\t')'''
#
# '''n = int(input('请输入鹅的数量：'))
# list_n = [int(i) for i in input('请输入每只鹅的身高，用空格隔开：').split()]
# for i in list_n:
#     print(max(list_n)-i,end = '\t')
# print()
# for i in list_n:
#     print(i -min(list_n),end = '\t')'''
#
#
# #幸运数字
# '''list_n= [int(i) for i in input('请输入两个数：').split()]
# l = list_n[1]
# r = list_n[0]
# sum = 0
# for i in range(r,l):
#     list_a = list(str(i))
#     list_b = list_a[::-1]
#     ji = 0
#     ou = 0
#     for index,n in enumerate(list_b):
#         if (index+1)%2:
#             ji = ji + int(n)
#
#         else:
#             ou = ou+int(n)
#
#     if ji ==ou:
#         sum = sum+1
# print(sum)'''
#
# '''list1 = ['name','age','gender']
# list2 = ['Tom',20,'man']
#
# dict1 ={list1[i]:list2[i] for i in range(len(list1))}
# print(dict1)
#
# counts = {'MBP':268,'HP':125,'DELL':201,'Lenovo':199,'acer':99}
#
# dict3 = {key:value for key ,value in counts.items() if value>=200}
# print(dict3)'''
#
# #精密计时
# '''str0 = '01:02:34.56 01:03:00.10'
# list_n=str0.split()
# list_a = str(list_n[0]).split(':')
# list_b = str(list_n[1]).split(':')
# hour_a = int(list_a[0])
# hour_b = int(list_b[0])
# minute_a = int(list_a[1])
# minute_b = int(list_b[1])
# s_a = list_a[2].split('.')
# s_b = list_b[2].split('.')
# sa = int(s_a[0])
# sb = int(s_b[0])
# sha = int(s_a[1])
# shb = int(s_b[1])
# print(hour_a,hour_b,minute_a,minute_b,sa,sb,sha,shb)
#
# sum_b=shb +sb*100+minute_b*60*100+hour_b*60*60*100
# sum_a = sha+sa*100+minute_a*60*100+hour_b*60*60*100
# sum = sum_b-sum_a
# print(sum)'''
#
# '''import time
# print(time.time())
# print(time.localtime())
# print(time.gmtime())'''
#
# '''if shb>=sha:
#     if sb>=sa:
#         if minute_b>=minute_a:
#             if hour_b>hour_a:
#                 sum = (shb-sha)+(sb-sa)*100+(minute_b - minute_a)*60*100+(hour_b - hour_a)*60*60*100
#         else:
#             hour_b=hou_b-1
#             if hour_b>hour_a:
#                 sum = (shb-sha)+(sb-sa)*100+(minute_b - minute_a)*60*100+(hour_b - hour_a)*60*60*100
#
#
#     else:
#         minute_b=minute_b-1
#         if minute_b>=minute_a:
#             if hour_b>hour_a:
#                 sum = (shb-sha)+(sb-sa)*100+(minute_b - minute_a)*60*100+(hour_b - hour_a)*60*60*100
#         else:
#             hour_b=hou_b-1
#             if hour_b>hour_a:
#                 sum = (shb-sha)+(sb-sa)*100+(minute_b - minute_a)*60*100+(hour_b - hour_a)*60*60*100
#
# else:
#     sb = sb-1
#     if sb>=sa:
#         if minute_b>=minute_a:
#             if hour_b>hour_a:
#                 sum = (shb-sha)+(sb-sa)*100+(minute_b - minute_a)*60*100+(hour_b - hour_a)*60*60*100
#         else:
#             hour_b=hou_b-1
#             if hour_b>hour_a:
#                 sum = (shb-sha)+(sb-sa)*100+(minute_b - minute_a)*60*100+(hour_b - hour_a)*60*60*100
#
#
#     else:
#         minute_b=minute_b-1
#         if minute_b>=minute_a:
#             if hour_b>hour_a:
#                 sum = (shb-sha)+(sb-sa)*100+(minute_b - minute_a)*60*100+(hour_b - hour_a)*60*60*100
#         else:
#             hour_b=hou_b-1
#             if hour_b>hour_a:
#                 sum = (shb-sha)+(sb-sa)*100+(minute_b - minute_a)*60*100+(hour_b - hour_a)*60*60*100
#
#
# print(sum)'''
# '''print(list_n)
# print(list_n[0])
# print(list_a)
# print(list_b)'''
#
# '''C={1,2,3}
# C.add(4)
# print(C)'''
#
# '''D = {1,2,3}
# D.update([4,5])
# print(D)'''
#
# '''def add_num2(a,b):
#     result = a+b
#     print(result)
# a = add_num2(10,20)
# print(a)'''
#
# '''def testB():
#     print(('testB start'.center(50,'*')).center(100))
#     print(('这里是testB函数执行的代码'.center(50)).center(100))
#     print(('testB end'.center(50, '*')).center(100))
# def testA():
#     print('testA start'.center(100,'-'))
#     testB()
#
# testA()
# testB()'''
#
# '''def print_line():
#     print('-'*10)
# def print_lines(num):
#     i= 0
#     while i <num:
#         print_line()
#         i+=1
# print_lines(5)'''
#
#
#
# '''def sum_num(a,b,c):
#     return a+b+c
#
# print(sum_num(10,35,6))''''''
# import time
# a= 100
# def testA():
#     print(a)
# def testB():
#     global a
#     a = 200
#     print(a)
# testA()
# testB()
# testBdef return_num():
#     return 100,200
# num1,num2 = return_num()
# print(num1)
# print(num2)
#
# dict1 = {'name':'Tom','age':18}
# a,b = dict1
# print(a)
# print(b)



# m ,n = [int(i) for i in input('输入两个整数：').split()]
# list_a = [[0 for i in range(n)]for i in range(m)]
# for i in range(m):
#     list_a[i]=[int(i) for i in input().split()]
# print(list_a)
# m ,n = [int(i) for i in input('输入两个整数：').split()]
# list_b = [[0 for i in range(n)]for i in range(m)]
# for i in range(m):
#     list_b[i]=[int(i) for i in input().split()]
# print(list_b)
# list_a = [[0,0,0],[0,1,1],[0,1,1]]
# list_b = [[1,1,0,0],[1,1,0,1]]
# l_a=0
# h_a=0
# l_b=0
# h_b=0
# sum = 0
# while l_a<len(list_a):
#
#     while h_a<len(list_a[0]):
#         while (l_b+l_a)<=len(list_a):
#             while (h_b+h_b)<=len(list_a[0]):
#                 print(list_a[h_a][l_a])
#                 if list_a[l_a][h_a]==list_b[l_b][h_b]:
#                     print(list_a[l_a][h_a])
#                     sum=sum+1
#                     print(sum)
#                 h_b=h_b+1
#             l_b=l_b+1
#             print('执行l_b=l_b+1')
#         h_a=h_a+1
#
#     l_a=l_a+1

# a = ['hello','world','yoyo','congratulations']
# m = 0
# for i in a:
#
#     if len(i)>m:
#         m = len(i)
#         s = i
# print(s)



# a = [1,-6,2,-5,9,4,20,-3]
# b=[]
# for i in range(len(a)):
#     if a[i]<0:
#         b.append(a[i])
#         a[i]=-a[i]
# c = sorted(a)
# for i in range(len(a)):
#     if -c[i ] in b:
#         c[i]=-c[i]
# print(c)
# import math
# a = [1,-6,2,-5,9,4,20,-3]
# a.sort(key = math.fabs)
# print(a)

# def test():
#     a = [1,-6,2,-5,9,4,20,-3]
#     lists = []
#     for i in a:
#         lists.append(abs(i))
#     lists.sort()
#     return lists
# print(test())

# ddict2 = {}
# for i in range(3):
#     dict1.popitem()
#
# print(dict1)
# print(dict2)
# dict1 = {'a':1,'b':2,'c':3}
# dict2 = {v:k for k ,v in dict1.items()}
# print(dict2)
# info=[]
# def add_info():
#     print('正在添加学生信息！'.center(20,'*'))
#     student_id = input("请输入学号：")
#     student_name = input('请输入姓名：')
#     student_tel = input('请输入电话号码：')
#
#     for i in info:
#         if student_name==i['name']:
#             print('用户已存在')
#             break
#     dict1 = {}
#     dict1['id'] = student_id
#     dict1['name']=student_name
#     dict1['tel'] = student_tel
#     info.append(dict1)
#     print('添加成功！'.center(20,'*'))
# add_info()
# # print(info)
# def del_info():
#     while True:
#         print('正在删除学生信息！'.center(20,'*'))
#         input_id= input('请输入要删除的学号：')
#         for i in info:
#             if input_id==i['id']:
#                 flag_tip = input('是否删除，请输入yes or no:')
#                 if flag_tip == 'yes':
#                     info.index(i)
#                     info.pop(info.index(i))
#                     print('已删除！'.center(20,'*'))
#             break
#         else:
#             print('请输入正确的id!')
# del_info()
# def modify_info():
#     while True:
#         input_id = int(input('请输入你要修改的学号：'))
#         if 0<=input_id<=len(info):
#             print(f'该学员学号是{info[input_id]['id']},姓名是{info[input_id]['name']},手机号是{info[input_id]['tel']}')
#             info[input_id]['id'] = input('请输入学号：')
#             info[input_id]['name']=input('请输入姓名:')
#             info[input_id]['tel'] = input('请输入手机号：')
#             break
#         else:
#             print('请输入正确的id：')
#
# def seach_info():
#     input_name=input('请输入要查询的名字：')
#     for i in info :
#         if i['name']==input_name:
#             print('***查询到以下信息***')
#             print(f'该学生学号是{i['id']},姓名是{i['name']},电话号码是{i['tel']}')
#             break
#     else:
#         print('查无此人')
# # seach_info()
#
# def print_all():
#     for i in info:
#         print(f'学号:{i['id']},姓名:{i['name']},电话号码:{i['tel']}')
#
# print_all()

# def num(n):
#     if n<0:
#         return 0
#     elif n==0:
#         return 3
#     else:
#         return ((num(n-1)+2)*2)
# print(num(5))
# print(lambda a,b :a if a >b else b)(100,50
# list1=[1,2,3,4,5]
# a = map(a+2,list1)
# pri
# class Washer():
#     def __init__(self,width,height):
#         self.width = width
#         self.height = height
#
#     def print_info(self):
#         print(f'洗衣机的宽度是{self.width}')
#         print(f'洗衣机的高度是{self.height}')
#
#     def __str__(self):
#         # return '这是海尔洗衣机的说明书\n'
#
#     def __del__(self):
#         print(f'{self}对象已经被删除')
#
# haier1 = Washer(10,20)
# haier1.print_info()

# class SweetPotato():
#     def __init__(self):
#         self.cook_time = 0
#         self.cook_static ='生的'
#         self.condiments = []
#     def cook(self,time):
#         self.cook_time +=time
#         if 0<=self.cook_time<3:
#             self.cook_static = '生的'
#         elif 3<=self.cook_time<5:
#             self.cook_static = '半生不熟'
#         elif 5<=self.cook_time<8:
#             self.cook_static = '熟了'
#         elif 8<=self.cook_time:
#             self.cook_static = '糊了'
#     def add_condiments(self,condiments):
#         self.condiments.append(condiments)
#     def __str__(self):
#         return f'这个地瓜烤了{self.cook_time}分钟，状态是{self.cook_static},添加的调料有{self.condiments}'
#
# digua1 = SweetPotato()
#
# digua1.cook(2)
# digua1.add_condiments('酱油')
#
# digua1.cook(2)
# digua1.add_condiments('辣椒面')
# print(digua1)

# class Home():
#     def __init__(self,address,area):
#         self.address = address
#         self.area = area
#         self.free_area = area
#         self.furniture =[]
#
#     def __str__(self):
#         return f'房子坐落于{self.address},占地面积{self.area},剩余面积{self.free_area},家具有{self.furniture}'
#
#     def add_furniture(self,item):
#         if self.free_area>=item.area:
#             self.furniture.append((item.name))
#             self.free_area -=item.area
#         else:
#             print('家具太大，剩余面积不足，无法容纳')
#
# class Furniture():
#     def __init__(self):
#         self.name = '床'
#         self.area = 1
#     def __str__(self):
#         return f'这个家具的名称是{self.name},占地面积为{self.area}'
#
# MyHome = Home('郑州',150)

# class Person():
#     def __init__(self,name,weight):
#         self.name = name
#
#         self.weight = weight
#     def __str__(self):
#         return f'{self.name}体重为{self.weight}公斤'
#
#     def run(self,n):
#         for i in range(n):
#             if self.weight>=40.5:
#                 self.weight-=0.5
#                 print(f'{self.name}刚才跑了100000m,减了0.5公斤，现在体重为{self.weight}公斤')
#             else :
#                 print('太瘦了，减不了')
#                 break
#
#
#     def eat(self,n):
#         for i in range(n):
#             if self.weight<=100:
#                 self.weight+=1
#                 print(f'{self.name}吃了很多，涨了1公斤，现在体重为{self.weight}公斤')
#
#             else:
#                 print('太胖了，吃不下了')
#                 break
#
# xiaoming = Person('小明',75)
# xiaomei = Person('小美',45)
#
# print(xiaoming)

# while True:
#     flag = int(input('跑步请输入1，吃东西请输入2：'))
#     n=1
#     if flag ==1:
#         xiaoming.run(n)
#     elif flag == 2:
#         xiaoming.eat(n)

# class A(object):
#     def __init__(self):
#         self.num=1
#     def info_print(self):
#         print(self.num)
#
# class B(A):
#     pass
#
# result = B()
# result.info_print()

class Master(object):
    def __init__(self):
        self.kongfu = '[古法煎饼果子配方]'
    def make_cake(self):
        print(f'运用{self.kongfu}制作煎饼果子')

# class Prentice(Master):
#     pass

# daqiu= Prentice('高永超')
# print(daqiu.kongfu)
# daqiu.make_cake()

# class School(object):
#     def __init__(self):
#         self.kongfu = '[新式煎饼果子配方]'
#
#     def make_cake(self):
#         print(f'运用{self.kongfu}制作煎饼果子')
#
# class Prentice(Master,School):
#     def __init__(self):
#         self.kongfu = '[独创煎饼果子配方]'
#     def make_cake(self):
#         self.__init__()
#         print(f'运用{self.kongfu}制作煎饼果子')
#     def make_master_cake(self):
#         Master.__init__(self)
#         Master.make_cake(self)
#     def make_school_cake(self):
#         School.__init__(self)
#         School.make_cake(self)
#
# class Tusun(Prentice):
#     pass
# # daqiu = Prentice()
# # daqiu.make_cake()
# # daqiu.make_master_cake()
# # daqiu.make_school_cake()
# xiaoqiu = Tusun()
# xiaoqiu.make_cake()
# xiaoqiu.make_school_cake()
# xiaoqiu.make_master_cake()

# class A(object):
#     def __init__(self):
#         print('class----A----')
#
# class B(A):
#     def __init__(self):
#         print('class----B----')
#         super(B,self).__init__()
#
# class C(A):
#     def __init__(self):
#         print('class----C----')
#         super(C,self).__init__()
#
# class D(B,C):
#     def __init__(self):
#         print('class----D----')
#         super(D,self).__init__()
#
# d = D()



# class triangle():
#     def __init__(self,a,b,c):
#         if not(a+b>c and a+c>b and b+c>a):
#             raise  ValueError('给定的边长不能构成一个三角形')
#         self.a = a
#         self.b = b
#         self.c = c
#
#     def calculate_size(self):
#         p = (self.a+self.b+self.c)/2
#         S = (p*(p-self.a)*(p-self.b)*(p-self.c))**(1/2)
#         print(f'三角形的面积是：{S}')
#
# san = triangle(2,2,5)
# san.calculate_size()
#
# class Dog(object):
#     def work(self):
#         print('指哪打哪---')
#
# class DrugDog

# class Dog(object):
#     tooth = 10
#
# wangcai = Dog()
# xiaogei = Dog()
# Dog.tooth = 12
# wangcai.tooth = 20
#
# print(Dog.tooth)
# print(wangcai.tooth)
# print(xiaogei.tooth)

# class Dog(object):
#     __tooth = 10
#     @classmethod
#     def get_tooth(cls):
#         return cls.__tooth
#
# wangcai = Dog()
# result = wangcai.get_tooth()
# print(result)

# import socket
#
# server = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
# server.bind(('localhost',8888))
#
# server.listen(5)
#
# client,addr = server.accept()
# print('客户端链接成功',addr)
# data = client.recv(1024)
# print('收到数据',data.decode())
# msg = input('请输入你要和客户端回复的消息：')
# client.send(msg.encode())
#
# client.close()
# server.close()

# import socket
#
# client = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
#
# client.connect(('127.0.0.1',8888))
#
# client.send('hello'.encode())
#
# data = client.recv(1025)
# print('客户端收到数据：',data.decode())
# client.close()

# import socket
# def scan_port(ip,port):
#     try:
#         sock = socket.socket(socket.AF_INET)

# import nmap
#
# def scan_with_nmap(target,ports = '')

import  socket
import  optparse

def port_scan(ip,port):

    try:
        s = socket.socket()

        s.settimeout(5)
        if s.connect_ex((ip,port))==0:
            print('[+] Host:{},Port{},Status: OPEN'.format(ip,port))
        else:
            print('[+] Host:{},Port{},Status: CLOSE'.format(ip, port))
    except Exception as e:
        print(e)
        pass
    finally:
        s.close()

def main():

    parser = optparse.OptionParser('<Usage>')
    parser.add_option('-i',dest = 'ip',type = 'string',help='target ip')
    parser.add_option('-p','--port',dest='ip', type='string', help='target port,可以用单个端口，也可以用一个端口范围，比如8000-9000')
    opts,args = parser.parse_args(1000,3000)
    ip = opts.ip
    port = opts.port
    if ip is None or port is None:
        print('请输入-h查看命令手册')
        return
    try:
        if '-' in port:
            start_port,end_port = port.split('-')
            for p in range(int(start_port),int(end_port)+1):
                port_scan(ip,p)
        else:
            port_scan(ip,int(port))
    except:
        print('请输入-h查看命令手册')

if __name__=='__main__':
    main()



